package com.sip.stream.utils.zfy.yuv;

import android.graphics.ImageFormat;
import android.media.Image;

import com.sip.stream.utils.ImageYUVBean;

public abstract class ICamera2ImageReader {
    protected int dataLength = 0;
    protected int height;
    protected int uvHeight;
    protected int uvPixelStride;
    protected int uvSize;
    protected int uvWidth;
    protected int width;
    protected int ySize;

    public abstract ImageYUVBean getDataFormImage(Image image);

    public ICamera2ImageReader(int i, int i2) {
        this.width = i;
        this.height = i2;
        setConfig();
    }

    protected void setConfig() {
        this.dataLength = ((this.width * this.height) * ImageFormat.getBitsPerPixel(35)) / 8;
        int i = this.width;
        int i2 = this.height;
        this.ySize = i * i2;
        int i3 = i / 2;
        this.uvWidth = i3;
        int i4 = i2 / 2;
        this.uvHeight = i4;
        this.uvSize = i4 * i3;
        this.uvPixelStride = 2;
    }

    public byte[] obtainOutputData(int i) {
        return YUVToolFactory.obtainOutputData(i);
    }

    public void recycle(byte[] bArr) {
        YUVToolFactory.recycleData(bArr);
    }
}
